package stu.aistar.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;
import stu.aistar.model.pojo.Movie;

import java.util.List;

@Component
public interface MovieMapper {
    List<Movie> findByConditionals(
            @Param("name") String name,
            @Param("city") String city,
            @Param("area") String area,
            @Param("c_id") String cid
    );

    @Select("select *from movie order by state desc")
    List<Movie> findAll();

    @Update("update movie set state = 0 where id = #{id} ")
    Integer delMoiveById(@Param("id")Integer id);

    @Update("update movie set state = 1 where id = #{id}")
    Integer showMovieById(@Param("id") Integer id);

    Integer delMoviesByIds(List<Integer> ids);

    Integer showMoviesByIds(List<Integer> ids);

    List<Movie> searchMovies(Movie movie);

    Integer insertMovie(Movie movie);

    @Select("select *from movie where name = #{name}")
    Movie findByName(@Param("name") String name);


    Integer updateMovieById(Movie movie);

    @Select("select *from movie where ciname_id = #{cid}")
    List<Movie> findByCid(@Param("cid") Integer id);

    @Select("select *from movie where state = 1")
    List<Movie> findAllMovies();

    @Select("select *from movie where id = #{id}")
    Movie findByMovieId(@Param("id") Integer id);
}
